#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@Filename      :decorator.py
@Description   :带参数的装饰器
@Datetime      :2020/09/15 14:17:26
@Author        :AshJo
@Version       :v1.0
"""

import time


def logger(path):
    def log(func):
        def inner(*args, **kwargs):
            ret = func(*args, **kwargs)
            with open(path, mode='a', encoding='utf-8') as f:
                msg = '%s 时间执行了 %s 函数\n' % (time.strftime('%Y-%m-%d %H:%M:%S'),
                                            func.__name__)
                f.write(msg)
            return ret

        return inner

    return log


@logger(r'Python_fullstack\day20\log\auth.log')
def login():
    print('登录逻辑')


@logger(r'Python_fullstack\day20\log\register.log')
def register():
    print('注册逻辑')


@logger(r'Python_fullstack\day20\log\goods.log')
def show_goods():
    print('展示商品')


@logger(r'Python_fullstack\day20\log\operate.log')
def add_goods():
    print('添加商品')


login()
show_goods()
